﻿package app.view.components.sections.expo 
{
	import app.model.types.SectionType;
	import app.model.vo.SectionVO;
	import app.view.components.buttons.BashnyaBtnBase;
	import app.view.components.header.HeadMarkerBase;
	import app.view.components.sections.LabeledSectionBase;
	import app.view.events.UIEvent;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * 1.1.2.3 СОСТАВ ЭКСПОЗИЦИЙ
	 * @author Dmitryi_Koruagin, icq:585466579, dmitryikoruagin@yandex.ru
	 */
	public class ExpoStructureExpositionsDBase extends LabeledSectionBase
	{
		// app.view.components.sections.expo.ExpoStructureExpositionsDBase
		
		
		//	public
		public var btn_bashnya_1:BashnyaBtnBase;
		public var btn_bashnya_2:BashnyaBtnBase;
		public var btn_bashnya_3:BashnyaBtnBase;
		public var btn_bashnya_4:BashnyaBtnBase;
		
		public var layer_1:Sprite;
		public var layer_2:Sprite;
		public var layer_3:Sprite;
		public var layer_4:Sprite;
		//	private
		
		//	const
		
		//	CONSTRUCTOR
		public function ExpoStructureExpositionsDBase() 
		{
			super();
		}
		
		override protected function init():void
		{
			super.init();
			
		}
		
		private function setEvents():void
		{
			btn_bashnya_1.addEventListener(MouseEvent.CLICK, onCLickBtn1);
			btn_bashnya_2.addEventListener(MouseEvent.CLICK, onCLickBtn2);
			btn_bashnya_3.addEventListener(MouseEvent.CLICK, onCLickBtn3);
			btn_bashnya_4.addEventListener(MouseEvent.CLICK, onCLickBtn4);
		}
		
		private function removeEvents():void
		{
			btn_bashnya_1.removeEventListener(MouseEvent.CLICK, onCLickBtn1);
			btn_bashnya_2.removeEventListener(MouseEvent.CLICK, onCLickBtn2);
			btn_bashnya_3.removeEventListener(MouseEvent.CLICK, onCLickBtn3);
			btn_bashnya_4.removeEventListener(MouseEvent.CLICK, onCLickBtn4);
		}
		
		override public function onDestroy():void 
		{
			// чистим что тут есть и вызываем супера
			removeEvents();
			
			btn_bashnya_1.destroy();
			btn_bashnya_2.destroy();
			btn_bashnya_3.destroy();
			btn_bashnya_4.destroy();
			
			super.onDestroy();
		};
		
		override public function get data():Object { return _data; };
		
		override public function set data(value:Object):void 
		{
			super.data = value;
			
			////trace('data!!!+++', _data.data);
			
			setParamHead(HeadMarkerBase.BGD_RED);
			
			btn_bashnya_1.setLang(_data.lang);
			btn_bashnya_2.setLang(_data.lang);
			btn_bashnya_3.setLang(_data.lang);
			btn_bashnya_4.setLang(_data.lang);
			
			
			setEvents();
		};
		
		
		private function onCLickBtn1(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_CURRENT_EXPOSITION;
			obj.currentId = id;
			obj.params = _data.data.cat[1];
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
		private function onCLickBtn2(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_CURRENT_EXPOSITION;
			obj.currentId = id;
			obj.params = _data.data.cat[2];
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
		private function onCLickBtn3(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_CURRENT_EXPOSITION;
			obj.currentId = id;
			obj.params = _data.data.cat[3];
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
		private function onCLickBtn4(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_EXPO_CURRENT_EXPOSITION;
			obj.currentId = id;
			obj.params = _data.data.cat[4];
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
	}

}